const router = require('express').Router();
const { addStu,getStu } = require("../model/stumodel")

router.get("/home",(req,res)=>{
    getStu().then(re=>{
        res.render("home",{
            students:re
        });
    }).catch(err=>{
        res.render("home",{
            students:[]
        });
    });
     
})
router.post("/addStu",async (req,res)=>{
    const params = req.body;
    console.log(params)
    let response = await addStu(params);
    console.log(response);
    res.send({
        code:0,
        msg:"插入成功"
    });
})
module.exports = router